/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package alg;

import util.DwConfigurationDerived;

/**
 *
 * @author Dragan
 */
public class EvaluationDerived extends Evaluation {

    double derivationCost;
    private DwConfigurationDerived config;

    public EvaluationDerived(DwConfigurationDerived config) {
        super(config);
        this.config = config;
    }

    @Override
    public double evaluate() {
        double value = super.evaluate();
        derivationCost = Maintenance.evaluateDerivation(config.getOldDomain(), config.getDomain());
        if (derivationCost > config.getAllowedDerivationCost()) {
            double RHO = config.getRho() * Math.pow((derivationCost - config.getAllowedDerivationCost()) / config.getAllowedDerivationCost() * 100, 2);
            RHO = RHO * 0.01;
            value += RHO * value;
        }
        return value;
    }

    public double getDerivationCost() {
        return derivationCost;
    }

    @Override
    public String toString() {
        String str = "";
        str += " queryCost:" + getQueryExecutionCost() + " maintCost:" + getViewMaintenanceCost() + " derivationCost:" + derivationCost + " totalCost:" + getTotalCost();
        return str;
    }
}
